﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Newton
{
    class Animation
    {
        public int frameWidth;
        public int frameHeight;
        public int frameCount;
        public int frameRate;
        public int mapY;
        public int mapX;
        public int currentFrame = 0;

        /// <summary>Indica se deve parar no fim da animação</summary>
        public bool stopEnd;

        private bool play;
        public string name;
        public double startTime = 0;

        public Animation(string name, int frameWidth, int frameHeight, int mapX, int mapY, int frameCount, int frameRate, bool stopEnd = false)
        {
            this.name = name;
            this.frameWidth = frameWidth;
            this.frameHeight = frameHeight;
            this.mapY = mapY;
            this.frameCount = frameCount;
            this.frameRate = frameRate;
            this.stopEnd = stopEnd;
            play = true;
        }

        public void GoToAndStop(int frame)
        {
            currentFrame = frame;
            play = false;
        }

        public void Play()
        {
            play = true;
        }

        public void Pause()
        {
            play = false;
        }

        public void Stop()
        {
            play = false;
            currentFrame = 0;
        }

        public void PlayFromInit()
        {
            play = true;
            currentFrame = 0;
        }

        public bool IsPlaying()
        {
            return play;
        }
    }
}
